﻿using Atha.Contracts;
using js = IronJS;

namespace Atha.Languages.IronJS
{
	public sealed class JsTestRunContext : ScriptTestRunContextBase
	{
		public JsTestRunContext(string name, string script)
			: base(name, script)
		{
		}

		protected override void OnExecute(string script, ITestRunResultBuilder testRunResultBuilder)
		{
			var js = new js.Hosting.CSharp.Context();

			var executionCtx = new CamelCaseTestExecutionContext(testRunResultBuilder);

			js.SetGlobal("atha", executionCtx);

			js.Execute(script);

			var postCtx = js.GetGlobalAs<CamelCaseTestExecutionContext>("atha");
		}
	}
}